while (<>) {
 chop;
# end of a record, so print what you have
if (/<\/REC>/) {
  print "$wos\t$type\t$year\t$journal\t$vol\t$issue\t$firstpage\t$lastpage\t$org\t$addr\t$firstauthor\t$doi\t$subject\t$title\n" if $wos ne "";
  $wos = "";
  $vol = "";
  $type = "";
  $year = "";
  $issue = "";
  $firstpage = "";
  $lastpage = "";
  $addr = "";
  $org = "";
  $doi = "";
  $journal = "";
  $firstauthor = "";
  $title = "";
  $doi = "";
  $subject = "";
 }
 if (/<UID>WOS:(.*)<\/UID>/) {
  $wos = $1; 
 }
 if (/<title type=\"source\">(.*)<\/title>/) {
  $journal = $1;
 }
 if (/<title type=\"item\">(.*)<\/title>/) {
  $title = $1;
 }
 if (/<wos_standard>(.*)<\/wos_standard>/ & $firstauthor eq "") {
  #print STDERR "author! $1\n";
   $firstauthor = $1;
 }
 if (/<pub_info(.*)/) {
  $pubinfo = $1;
  $type = $1 if ($pubinfo =~ /pubtype=\"([^\"]*)\"/);
  $year = $1 if ($pubinfo =~ /pubyear=\"([^\"]*)\"/);
  $vol = $1 if ($pubinfo =~ /vol=\"([^\"]*)\"/);
  $issue = $1 if ($pubinfo =~ /issue=\"([^\"]*)\"/);
 }
 $firstpage = $1 if (/page begin=\"([^\"\-]*)\" end=\"[^\"\-]*()\"/);
 $lastpage = $2 if (/page begin=\"([^\"\-]*)\" end=\"([^\"\-]*)\"/);
#<page begin="1" end="16" page_count="16">1-16</page>
 if (/<full_address>(.*)<\/full_address>/ & $addr eq "") {
  $addr = $1;
 }
 if (/<organization>(.*)<\/organization>/ & $org eq "") {
  #print STDERR "org! $1\n";
  $org = $1;
 }
 if (/<subject ascatype=\"traditional\">(.*)<\/subject>/ & $subject eq "") {
  #print STDERR "subject! $1\n";
  $subject = $1;
 }
 if (/<doi>(.*)<\/doi>/) {
  #print STDERR "doi! $doi\n";
  $doi = $1;
 }
}
